{% extends "base.html" %}
{% block title %}设置新密码{% endblock %}

{% block content %}
<div class="container">
    <div class="row">
        <div class="col-md-8 offset-md-2">
            <div class="card">
                <div class="card-header">
                    <h4>设置新密码</h4>
                </div>
                <div class="card-body">
                    {% if validlink %}
                        <p>请输入并确认您的新密码。</p>
                        <form method="post">
                            {% csrf_token %}
                            
                            <!-- 密码输入字段 -->
                            <div class="form-group">
                                <label for="id_new_password1">新密码:</label>
                                {{ form.new_password1.errors }}
                                <input type="password" name="new_password1" class="form-control" required id="id_new_password1">
                                <small class="form-text text-muted">
                                    <ul>
                                        <li>密码不能与其他个人信息太相似。</li>
                                        <li>密码必须至少包含8个字符。</li>
                                        <li>密码不能是常用密码。</li>
                                        <li>密码不能全是数字。</li>
                                    </ul>
                                </small>
                            </div>

                            <!-- 密码确认字段 -->
                            <div class="form-group">
                                <label for="id_new_password2">确认密码:</label>
                                {{ form.new_password2.errors }}
                                <input type="password" name="new_password2" class="form-control" required id="id_new_password2">
                                <small class="form-text text-muted">请再次输入相同的密码进行确认。</small>
                            </div>

                            <!-- 提交按钮 -->
                            <button type="submit" class="btn btn-primary mt-3">确认修改</button>
                        </form>
                    {% else %}
                        <div class="alert alert-danger">
                            <p>密码重置链接无效！</p>
                            <p>可能是因为它已经被使用过。请重新申请重置密码。</p>
                        </div>
                        <a href="{% url 'password_reset' %}" class="btn btn-primary">重新申请重置密码</a>
                    {% endif %}
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}